from .base import Base, db


class Organization(Base):

    __tablename__ = 'organizations'

    code = db.Column(db.String(10), unique=True)
    name = db.Column(db.String(50), nullable=False)
    parent_code = db.Column(db.String(50), nullable=False)
    parent_codes = db.Column(db.String(250), nullable=False)

    def __init__(self, code, name, parent_code, parent_codes, create_user, update_user):
        super(Organization, self).__init__(create_user, update_user)
        self.code = code
        self.name = name
        self.parent_code = parent_code
        self.parent_codes = parent_codes

    def __repr__(self):
        desc = 'Organization:{'
        for key in self.__dict__:
            desc += '%s:%s\n' % (key, self.__dict__[key])
        return desc % '}'